{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "from common import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "CONSUMPTION = {\n",
    "    \"FASTER\"   : (15.5, 8),\n",
    "    \"Viper\"    : (21.2, 2.35),  \n",
    "    \"Dash\"     : (23.8 + 2.1, 0),\n",
    "    \"µTree\"    : (23.8, 9.0),\n",
    "    \"PmemKV\"   : (51.7, 0),\n",
    "    \"CrlStore\" : (1.1 + 39.8, 27.8),\n",
    "}\n",
    "\n",
    "fixtures, sizes = zip(*CONSUMPTION.items())\n",
    "pmem, dram = zip(*sizes)\n",
    "\n",
    "plt.rcParams.update({'hatch.color': 'white', 'hatch.linewidth': 2})\n",
    "ind = np.arange(len(fixtures))\n",
    "\n",
    "fig, ax = plt.subplots(1, 1, figsize=(3.5, 2))\n",
    "\n",
    "ax.bar(ind, pmem, label='PMem', color=PMEM_COLOR, lw=2, hatch='')\n",
    "ax.bar(ind, dram, bottom=pmem, label='DRAM', color=DRAM_COLOR, lw=2, hatch='')\n",
    "\n",
    "# ax.set_ylim(0, 55)\n",
    "y_ticks = range(0, 71, 10)\n",
    "ax.set_yticks(y_ticks)\n",
    "ax.set_yticklabels(['0', '', '20', '', '40', '', '60', ''], fontsize=20)\n",
    "ax.set_xticks(ind)\n",
    "ax.set_xticklabels(fixtures, fontsize=16, rotation=45)\n",
    "\n",
    "ax.set_ylabel(\"Total Memory (GB)\", fontsize=18)\n",
    "ax.yaxis.set_label_coords(-0.2, 0.28)\n",
    "\n",
    "handles, labels = ax.get_legend_handles_labels()\n",
    "fig.legend(handles[::-1], labels[::-1], bbox_to_anchor=(0.32, 0.95), loc='upper center',\n",
    "           ncol=1, frameon=True, fontsize=20, facecolor='white', framealpha=0, edgecolor='white',\n",
    "           columnspacing=0.5, handletextpad=0.3, labelspacing=0.1, handlelength=1.4)\n",
    "\n",
    "ax.set_axisbelow(True)\n",
    "ax.grid(axis='y', which='both')\n",
    "hide_border(ax)\n",
    "\n",
    "fig.savefig('charts/memory.pdf', bbox_inches='tight')\n",
    "fig.savefig('charts/memory.svg', bbox_inches='tight')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
